package com.kxj.gaode;

import com.amap.api.maps.AMapException;
import com.amap.api.maps.offlinemap.OfflineMapManager;
import com.amap.api.maps.offlinemap.OfflineMapManager.OfflineMapDownloadListener;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

public class LoadOfflineMapService extends Service implements OfflineMapDownloadListener {
	private String TAG = "GaodePlugin";
	@Override
	public IBinder onBind(Intent arg0) {
		return null;
	}
	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		String cityCode="021";
		
		//构造OfflineMapManager对象 
		OfflineMapManager amapManager = new OfflineMapManager(this, this);
		try {
			//按照citycode下载
			//amapManager.downloadByCityCode(cityCode);
			//按照cityname下载
			amapManager.downloadByCityName("上海市");
		} catch (AMapException e) {
			e.printStackTrace();
		}
		
		
		return START_STICKY;
	}
	/* 
	 * status 下载状态,参照OfflineMapStatus
	 * completeCode下载进度
	 * name 下载的城市的名字
	 */
	@Override
	public void onDownload(int status, int completeCode, String name) {
		Log.i(TAG, "下载进度:"+completeCode+"%");
		
	}
	@Override
	public void onCheckUpdate(boolean paramBoolean, String paramString) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void onRemove(boolean paramBoolean, String paramString1,
			String paramString2) {
		// TODO Auto-generated method stub
		
	}
	
}
